package demo1;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //寻找数组的下标中心
    public int pivotIndex(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];
        int[] g = new int[n];
        f[0] = 0;
        for (int i = 1; i < n; i++) {
            f[i] = f[i-1]+nums[i-1];
        }
        g[n-1] = 0;
        for (int i = n-2; i >= 0 ; i--) {
            g[i] = g[i+1] + nums[i+1];
        }
        for (int i = 0; i < n; i++) {
            if(f[i] == g[i]) return i;
        }
        return -1;
    }


    //二维前缀和 模板
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        int q = in.nextInt();
        int[][] array = new int[x+1][y+1];
        long[][] dp = new long[x+1][y+1];
        for(int i = 1;i<=x;i++){
            for(int j = 1;j<=y;j++){
                array[i][j] = in.nextInt();
                dp[i][j] = dp[i-1][j]+dp[i][j-1]+(long)array[i][j]-dp[i-1][j-1];
            }
        }

        while(q>0){
            q--;
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            long ret = dp[x2][y2]-dp[x2][y1-1]-dp[x1-1][y2]+dp[x1-1][y1-1];
            System.out.println(ret);
        }
    }

    //前缀和 模板
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int[] array = new int[n+1];
        long[] dp = new long[n+1];
        for(int i = 1;i<=n;i++){
            array[i] = in.nextInt();
            dp[i] = dp[i-1] + array[i];
        }
        while(q>0){
            q--;
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(dp[r]-dp[l-1]);
        }
    }

    //搜索旋转排序数组
    public int search(int[] nums, int target) {
        int n = nums.length;
        int left = 0;
        int right = n-1;
        while (left < right) {
            int mid = left+(right-left)/2;
            if(nums[mid]>nums[n-1]) left = mid+1;
            else right = mid;
        }
        if(target<=nums[n-1]){
            right = n-1;
            while(left<right){
                int mid = left+(right-left)/2;
                if(nums[mid]<target) left = mid+1;
                else right = mid;
            }
            if(nums[right] == target) return right;
            else return -1;
        }else{
            left = 0;
            right = right == 0?0:right-1;
            while(left<right){
                int mid = left+(right-left)/2;
                if(nums[mid]<target) left = mid+1;
                else right = mid;
            }
            if(nums[right] == target) return right;
            else return -1;
        }
    }

    //搜索旋转排序数组中的最小值
    public int findMin(int[] nums) {
        int n = nums.length;
        int left = 0;
        int right = n-1;
        while (left < right) {
            int mid = left+(right-left)/2;
            if(nums[mid]>nums[n-1]) left = mid+1;
            else right = mid;
        }
        return nums[right];
    }
}
